package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void click(View view){
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment_wechat f1 = new Fragment_wechat();
        Fragment_contacts f2 = new Fragment_contacts();
        Fragment_discover f3 = new Fragment_discover();
        Fragment_me f4 = new Fragment_me();

        if (view.getId() == R.id.wechat)
        {
            ft.replace(R.id.content,f1);
        }
        if (view.getId() == R.id.contacts)
        {
            ft.replace(R.id.content,f2);
        }
        if (view.getId() == R.id.discover)
        {
            ft.replace(R.id.content,f3);
        }
        if(view.getId() == R.id.me)
        {
            ft.replace(R.id.content,f4);
        }
        ft.commit();
    }
}